import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/chenyi";

// 查询商户管理列表
export function listShop(query) {
  return request({
    url: '/shop/shop/list',
    method: 'get',
    params: query
  })
}

// 查询商户管理详细
export function getShop(shopId) {
  return request({
    url: '/shop/shop/' + praseStrEmpty(shopId),
    method: 'get'
  })
}

// 新增商户管理
export function addShop(data) {
  return request({
    url: '/shop/shop',
    method: 'post',
    data: data
  })
}

// 修改商户管理
export function updateShop(data) {
  return request({
    url: '/shop/shop',
    method: 'put',
    data: data
  })
}

// 删除商户管理
export function delShop(shopId) {
  return request({
    url: '/shop/shop/' + shopId,
    method: 'delete'
  })
}

// 导出商户管理
export function exportShop(query) {
  return request({
    url: '/shop/shop/export',
    method: 'get',
    params: query
  })
}


// 用户密码重置
export function resetShopPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/shop/resetPwd',
    method: 'put',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/shop/changeStatus',
    method: 'put',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/shop/profile',
    method: 'get'
  })
}
// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/shop/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/shop/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/shop/profile/avatar',
    method: 'post',
    data: data
  })
}
